import { _decorator, Component, Node, Animation, Label } from 'cc';
import { Global } from '../Global';
import { HeroState } from './State/HeroState';
const { ccclass, property } = _decorator;

@ccclass('Hero')
export class Hero extends Component {

    @property(Animation)
    anim: Animation = null

    _heroState = {
        'state': {
            'state': '正常',
            'level': 1,
            'money': 100,
            'exper': 1000,
        },
        'fight': {
            'life': 2000,
            'defense': 20,
            'magicDefense': 20,
            'atk': 20,
        },
        'keys': {
            'yellow': 1,
            'blue': 0,
            'red': 0,
            'green': 0
        },
    }

    start() {
        Global.hero = this
        this.anim = this.getComponent(Animation)
    }

    startAnim(dir: string) {
        this.anim.play(dir)
    }

    stopAnim() {
        this.anim.stop()
    }


    initHeroState() {

    }

    addExper(exper: number) {
        this._heroState.state.exper += exper
    }
}

